import { addPlayerToMatch, getMatchPlayers } from '../models/matchPlayer.js'

export const addPlayer = async (req, res) => {
  try {
    const { matchId, playerId } = req.body
    const result = await addPlayerToMatch(matchId, playerId)
    res.json({ id: result })
  } catch (error) {
    res.status(500).json({ error: error.message })
  }
}

export const getPlayers = async (req, res) => {
  try {
    const { matchId } = req.params
    const players = await getMatchPlayers(matchId)
    res.json(players)
  } catch (error) {
    res.status(500).json({ error: error.message })
  }
} 